package net.lab1024.sa.admin.module.upstream.box;

import cn.dev33.satoken.annotation.SaCheckPermission;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import net.lab1024.sa.admin.constant.AdminSwaggerTagConst;
import net.lab1024.sa.admin.module.device.terminal.domain.DeviceTerminalVO;
import net.lab1024.sa.admin.module.system.login.domain.RequestEmployee;
import net.lab1024.sa.admin.module.upstream.box.domain.UpstreamBoxQueryForm;
import net.lab1024.sa.admin.module.upstream.box.domain.UpstreamBoxVO;
import net.lab1024.sa.admin.util.AdminRequestUtil;
import net.lab1024.sa.base.common.domain.PageResult;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Tag(name = AdminSwaggerTagConst.Upstream.UPSTREAM_BOX)
public class UpstreamBoxController {

    private final UpstreamBoxService upstreamBoxService;

    public UpstreamBoxController(UpstreamBoxService upstreamBoxService) {
        this.upstreamBoxService = upstreamBoxService;
    }

    @Operation(summary = "分页查询")
    @PostMapping("/upstream/box/page/query")
    @SaCheckPermission("upstream:box:query")
    public ResponseDTO<PageResult<UpstreamBoxVO>> queryByPage(@RequestBody UpstreamBoxQueryForm queryForm) {
        RequestEmployee requestUser = AdminRequestUtil.getRequestUser();
        PageResult<UpstreamBoxVO> pageResult = upstreamBoxService.queryByPage(queryForm, requestUser);
        return ResponseDTO.ok(pageResult);
    }
}
